<?php

print '
<div class="module">
	<h3 onclick="CMS.toggleSection(this);">Recent Content Edits</h3>
	<div class="content">
	<table class="data_grid">
		<thead>
			<tr>
			<th>Table</th>
			<th>Id</th>
			<th>Action</th>
			<th>User</th>
			<th>Time</th>
			</tr>
		</thead>
		<tbody class="records">';
		
if ($q = $this->db->query("SELECT * FROM ".BLACKBIRD_TABLE_PREFIX."history ORDER BY modtime DESC LIMIT 5")) {
	$rc = 0;
	foreach($q as $row){
		($rc%2==0) ? $class='' : $class='class="odd"';
		$click = 'onclick="window.location = \'' . BLACKBIRD_ROOT . 'edit/'.BLACKBIRD_TABLE_PREFIX.'history/' . $row['id'] . '\';"';
		$deets = $this->db->queryRow("SELECT firstname,lastname,email FROM " . BLACKBIRD_USERS_TABLE . " WHERE id = '$row[user_id]'");
		print "<tr $class>";
		print "<td $click>" . $row['table_name'] . '</td>';
		print "<td $click>" . $row['record_id'] . '</td>';
		print "<td $click>" . $row['action'] . '</td>';
		print "<td $click>" . $deets['lastname'] . ', ' . $deets['firstname'] . '</td>';
		print "<td $click>" . $row['modtime'] . '</td>';			
		print '</tr>';
	
		$rc++;
	}
}

print '</tbody>
</table>
</div>
</div>';